<template>
  <div class="goodsAdd">
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>商品添加</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片区域 -->
    <el-card>
      <!-- 提示 -->
      <el-alert title="添加商品信息" type="info" :closable="false" center show-icon></el-alert>
      <el-steps :space="300" :active="activeName-0" :align-center="true" finish-status="success">
        <el-step title="基本信息"></el-step>
        <el-step title="商品参数"></el-step>
        <el-step title="商品属性"></el-step>
        <el-step title="商品图片"></el-step>
        <el-step title="商品内容"></el-step>
        <el-step title="完成"></el-step>
      </el-steps>
      <el-form :model="addGoodsForm" :rules="rules" ref="addGoodsForm">
        <el-tabs :before-leave="beforeLeave" v-model="activeName" tab-position="left">
          <el-tab-pane label="基本信息" name="0">
            <el-form-item label="商品名称" prop="goods_name">
              <el-input v-model="addGoodsForm.goods_name"></el-input>
            </el-form-item>
            <el-form-item label="商品价格" prop="goods_price">
              <el-input type="number" v-model="addGoodsForm.goods_price"></el-input>
            </el-form-item>
            <el-form-item label="商品重量" prop="goods_weight">
              <el-input type="number" v-model="addGoodsForm.goods_weight"></el-input>
            </el-form-item>
            <el-form-item label="商品数量" prop="goods_number">
              <el-input type="number" v-model="addGoodsForm.goods_number"></el-input>
            </el-form-item>
            <el-form-item label="商品分类" prop="goods_cat">
              <br />
              <el-cascader
                v-model="cascaderArr"
                :options="cascaderList"
                :props="cascaderProps"
                @change="handleChange"
              ></el-cascader>
            </el-form-item>
          </el-tab-pane>
          <el-tab-pane label="商品参数" name="1">
            <el-form-item v-for="item in manyList" :key="item.attr_id" :label="item.attr_name">
              <br />
              <el-tag
                :style="{'display':item2==''?'none':'inner-block','margin-right':'5px'}"
                v-for="(item2,index) in item.attr_vals"
                :key="index"
              >{{item2}}</el-tag>
            </el-form-item>
          </el-tab-pane>
          <el-tab-pane label="商品属性" name="2">
            <el-form-item v-for="(item,index) in onlyList" :key="index" :label="item.attr_name">
              <el-input v-model="item.attr_vals"></el-input>
            </el-form-item>
          </el-tab-pane>
          <el-tab-pane label="商品图片" name="3">
            <el-upload
              class="upload-demo"
              action="http://127.0.0.1:8888/api/private/v1/upload"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :on-success="handleSuccess"
              list-type="picture"
              :headers="headers"
            >
              <el-button size="small" type="primary">点击上传</el-button>
            </el-upload>
          </el-tab-pane>
          <el-tab-pane label="商品内容" name="4">
            <el-form-item>
              <quill-editor v-model="addGoodsForm.goods_introduce"></quill-editor>
            </el-form-item>
            <el-row>
              <el-button type="primary" @click="addGoods">添加商品</el-button>
            </el-row>
          </el-tab-pane>
        </el-tabs>
      </el-form>
    </el-card>
    <!-- 查看图片弹出框 -->
    <el-dialog title="图片预览" :visible.sync="dialogSrcVisible">
      <img style="width:100%;height:100%" :src="imgSrc" />
    </el-dialog>
  </div>
</template>
<script>
import goodsAdd from "./goodsAdd-mixins";
export default {
  mixins: [goodsAdd]
};
</script>
<style lang="less" scoped>
.el-card {
  // overflow: initial;
  margin-top: 15px;
}
.el-steps {
  margin-top: 15px;
}
.el-tabs {
  margin-top: 15px;
}
.quill-editor {
  height: 300px;
}
.el-row {
  margin-top: 75px;
}
</style>
